package com.example.androidapp2;

import com.xyzdesa.droidnomy.R;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class PopUpConfig extends Dialog   {
	DbAdapter DbConect;
	Context Ctx;

	SeekBar skCierreMes;	
	TextView lblValorCambio;
	Button btnGuardar;

	public PopUpConfig(Context context, DbAdapter db) {
		super(context);		
		this.setContentView(R.layout.pup_config);
		Ctx = context;
		DbConect = db;
		this.setTitle(Ctx.getResources().getString(R.string.pupConfig));

		skCierreMes = (SeekBar) findViewById(R.id.skCierreMes);
		btnGuardar = (Button) findViewById(R.id.btnGuardar);
		lblValorCambio = (TextView) findViewById(R.id.lblValorCambio);
		
		skCierreMes.setMax(28);
		int cambio = DbConect.GetDiaCambioMes();
		skCierreMes.setProgress(cambio);
		lblValorCambio.setText(String.valueOf(cambio));
		
		skCierreMes.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

			public void onStopTrackingTouch(SeekBar seekBar) {}

			public void onStartTrackingTouch(SeekBar seekBar) {}

			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
				lblValorCambio.setText(String.valueOf(progress));
			}
		});

		btnGuardar.setOnClickListener(new View.OnClickListener() {			
			public void onClick(View v) {
				DbConect.SetDiaCambioMes(skCierreMes.getProgress());
				hide();
			}
		});
	}
}